import React from 'react';
import { View, StyleSheet, Linking, Button, Platform, ScrollView } from 'react-native';

import DemoContainer from '@common/demoContainer';

export default function App({ route }: any) {
    const { params = {} } = route;
    const urls = [
        {
            url: 'rnsample://rn.sample.com',
            name: t('api.Linking.openURL.openRnSample')
        },
        {
            url: 'https://www.baidu.com',
            name: t('api.Linking.openURL.openBaidu')
        },
        {
            url: Platform.OS === 'harmony' ?
                'store://appgallery.huawei.com/app/detail?id=com.huawei.hmsapp.books' :
                'market://com.huawei.appmarket.applink?id=com.huawei.hmsapp.books',
            name: t('api.Linking.openURL.openHuaweiAppMarket')
        },
        {
            url: 'tel:123456789',
            name: t('api.Linking.openURL.callNumber')
        },
        {
            url: 'sms:123456789',
            name: t('api.Linking.openURL.sendSms')
        }
    ]

    return (
        <DemoContainer params={params}>
            <ScrollView style={styles.container}>
                {
                    urls.map((item, index) => {
                        return (
                            <View key={index} style={{ marginTop: 10, marginBottom: 10 }}>
                                <Button
                                    title={item.name}
                                    onPress={() => {
                                        Linking.openURL(item.url)
                                    }}
                                    color="#007AFF" // 设置按钮颜色
                                />
                            </View>
                        )
                    })
                }
            </ScrollView>
        </DemoContainer>

    );
}

const styles = StyleSheet.create({
    container: {
        flexDirection: 'column',
    }
});
